#include <bits/stdc++.h>
#define re register
#define int long long
#define Add(a,b) (((a) + (b)) % mod)
#define Mul(a,b) ((a) * (b) % mod)
#define chAdd(a,b) (a = Add(a,b))
#define chMul(a,b) (a = Mul(a,b))

using namespace std;

const int N = 25,M = 6010;
const int mod = 998244353;
int n,m;
int arr[N],brr[N];

inline int read(){
    int r = 0,w = 1;
    char c = getchar();
    while (c < '0' || c > '9'){
        if (c == '-') w = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9'){
        r = (r << 3) + (r << 1) + (c ^ 48);
        c = getchar();
    }
    return r * w;
}

inline int qmi(int a,int b){
    int res = 1;
    while (b){
        if (b & 1) chMul(res,a);
        chMul(a,a); b >>= 1;
    } return res;
}

namespace Sub1{
    inline void solve(){ printf("%lld",qmi(arr[1],m)); }
}

namespace Sub2{
    int dp[N][M];

    inline bool check(){
        for (re int i = 1;i <= n;i++){
            if (brr[i] > 300) return false;
        } return true;
    }

    inline void solve(){
        for (re int i = 0;i <= n;i++) dp[i][0] = 1;
        for (re int i = 1;i <= n;i++){
            for (re int j = 1;j <= m;j++){
                for (re int k = 0,v = 1;k <= min(j,brr[i]);k++,chMul(v,arr[i])) chAdd(dp[i][j],Mul(dp[i - 1][j - k],v));
                // ,cerr << i << " " << j << " " << k << " " << v << " !!!\n";
                // cerr << i << " " << j << " " << dp[i][j] << " ???\n";
            }
        } printf("%lld",dp[n][m]);
    }
}

signed main(){
    freopen("yt.in","r",stdin);
    freopen("yt.out","w",stdout);
    n = read(),m = read();
    for (re int i = 1;i <= n;i++) arr[i] = read(),brr[i] = read();
    if (n == 1) Sub1::solve();
    else if (Sub2::check()) Sub2::solve();
    return 0;
}